import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class NodePublisher(Node):
    def __init__(self,name):
        super().__init__(name)
        self.get_logger().info("This is a publisher:{}".format(name))
        self.timer_period = 2
        self.command_publisher = self.create_publisher(String,'command',10)
        # timer is the signal of publish for command_pulisher
        self.timer = self.create_timer(self.timer_period,self.timer_callback)
    
    def timer_callback(self):
        msg = String()
        msg.data = 'backup'
        self.command_publisher.publish(msg)
        self.get_logger().info(f'publish order:{msg.data}')
def main(args=None):
    rclpy.init(args=args) 
    node = NodePublisher("topic_puser") 
    rclpy.spin(node) 
    rclpy.shutdown() 
